﻿using System;
using System.Runtime.CompilerServices;

namespace C4Net.Core.Log
{
    /// <summary>
    /// Base class for objects that can write a log.
    /// </summary>
    public class LoggableClass     
    {
        #region - Methods -

        /// <summary>
        /// Writes a message into a given logger.
        /// </summary>
        /// <param name="severity">The severity of the issue.</param>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void WriteLog(LogSeverity severity, string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.WriteLog(severity, message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Writes an exception into a given logger.
        /// </summary>
        /// <param name="severity">The severity of the issue.</param>
        /// <param name="ex">The exception.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void WriteLog(LogSeverity severity, Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.WriteLog(severity, ex, this.GetType().FullName, memberName);
        }


        /// <summary>
        /// Logs a debug message into the default logger.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogDebug(string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogDebug(message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs a debug exception into the default logger.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogDebug(Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogDebug(ex, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs an information message into the default logger.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogInfo(string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogInfo(message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs an information exception into the default logger.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogInfo(Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogInfo(ex, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs a warning message into the default logger.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogWarning(string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogWarning(message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs a warning exception into the default logger.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogWarning(Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogWarning(ex, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs an error message into the default logger.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogError(string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogError(message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs an error exception into the default logger.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogError(Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogError(ex, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs a fatal message into the default logger.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogFatal(string message, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogFatal(message, this.GetType().FullName, memberName);
        }

        /// <summary>
        /// Logs a fatal exception into the default logger.
        /// </summary>
        /// <param name="ex">The exception.</param>
        /// <param name="memberName">Name of the member.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void LogFatal(Exception ex, [CallerMemberName] string memberName = "")
        {
            DefaultLogger.LogFatal(ex, this.GetType().FullName, memberName);
        }

        #endregion
    }
}
